class Solution {
    public static void duplicateZeros(int[] arr) {
        int cur=0;
        int dest=-1;
        while(cur<arr.length){
            if(arr[cur]!=0){
                dest++;
            }else{
                dest=dest+2;
            }
            if(dest>=arr.length-1){
                break;
            }
            cur++;
        }
        if(dest==arr.length){
            arr[dest--]=0;
            cur--;
            dest--;
        }
        while(cur>=0&&dest>=0){
            if(arr[cur]!=0){
                arr[dest--]=arr[cur--];
            }else{
                arr[dest--]=0;
                arr[dest--]=0;
                cur--;
            }
        } 
    }

        public static boolean isHappy(int n) {
            int slow=n,fast=bitsum(n);
            while(fast!=slow){
                slow=bitsum(slow);
                fast=bitsum(bitsum(fast));
            }
            if(slow==1){
                return true;
            }else{
                return false;
            }
        }
        public static int bitsum(int n) {
            int sum = 0;
            while (n != 0) {
                int k = n % 10;
                sum += k * k;
                n = n / 10;
            }
            return sum;
        }

}